var _a;
var isDone = false; // Boolean
var isNumber = 0; // number
var isString = ''; // string
var sym = Symbol(); // symbol
var obj = (_a = {},
    _a[sym] = 'semlinker',
    _a);
// 数组 两种方式，一种直接语法，一种泛型语法
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [1, 2, 3, 4, 5];
var dir = 0 /* NORTH */; // 默认值为0,1,2,3,4，自动增长
var dir1 = 0 /* NORTH */; // 'NORTH'
//常量枚举 添加const关键词即可
// 异构枚举 数字和字符串的组合
var Direaction2;
(function (Direaction2) {
    Direaction2[Direaction2["DIRECTION"] = 0] = "DIRECTION";
    Direaction2[Direaction2["NORTH"] = 1] = "NORTH";
    Direaction2["SOUTH"] = "SOUTH";
    Direaction2["EAST"] = "EAST";
    Direaction2[Direaction2["WEST"] = 2] = "WEST";
})(Direaction2 || (Direaction2 = {}));
// 这里会出现反向映射
console.log(Direaction2[0]); // 'DIRECTION'
console.log(Direaction2.DIRECTION); // 0
// any类型
var notSure = 66;
// unknown
var value;
// 元组类型
var pupleType = ['1', 1];
// void 类型
function test() {
    console.log('this is a void type function');
}
// null undefined
var someValue = 'this is a string';
var strLength = someValue.length;
var someValue1 = 'this is a string';
var strLength1 = someValue1.length;
function myFunc(maybeString) {
    var onlyString = maybeString;
}
var getStr = function (str) { return parseInt(str, 10); };
// 定义对象数组
var arr = [{ age: 'dell' }];
var arr3 = [{ name: '12', age: 12 }];
// 甚至可以定义一个类对象数组
var Teacher = /** @class */ (function () {
    function Teacher() {
    }
    return Teacher;
}());
var arr4 = [new Teacher(), { name: '12', age: 12 }];
// 二位数组 + 元祖定义
var demo1 = [
    ['1', 2, '1'],
    ['2', 3, '3']
];
var getPersonName = function (person) { return person.name; };
var setPersonName = function (person, name) {
    person.name = name;
};
var getPersonName1 = function (person) { return person.name; };
// type 和 interface 的区别是 type可以去表示基础类型，接口只能表示对象
getPersonName1({ name: '1', age: 11 });
// 类型断言 你比 TS 更加知道类型，因为TS在联合类型下只会去取公有属性
// as
function trainAnial(animal) {
    if (animal.fly) {
        ;
        animal.sing();
    }
    else {
        ;
        animal.bark();
    }
}
// in 判断属性名是否在该对象
function trainAnials(animal) {
    if ('sing' in animal) {
        animal.sing();
    }
    else {
        animal.bark();
    }
}
// 类型保护 typeof instanceof
var addFirst = function (num1, num2) {
    if (typeof num1 === 'string' || typeof num2 === 'string') {
        return "" + num1 + num2;
    }
    return num1 + num2;
};
